package com.hy.mydesktop.client.component.factory;

import com.extjs.gxt.ui.client.widget.layout.FormData;
import com.hy.mydesktop.client.component.meta.FormDataModelEnum;
import com.hy.mydesktop.shared.persistence.domain.gxt.GxtComponentMetaNodeModel;

/**
 * 
 * <ul>
 * <li>开发作者：冬超</li>
 * <li>设计日期：2010-8-31；时间：下午03:28:02</li>
 * <li>类型名称：FormDataFactory</li>
 * <li>设计目的：</li>
 * </ul>
 * <ul>
 * <b>修订编号：</b>
 * <li>修订日期：</li>
 * <li>修订作者：</li>
 * <li>修订原因：</li>
 * <li>修订内容：</li>
 * </ul>
 */
public class FormDataFactory {
	public static FormData createFormData(
			GxtComponentMetaNodeModel gxtComponentMetaNodeModel) {

		return configureFormData(gxtComponentMetaNodeModel);

	}

	private static FormData configureFormData(
			GxtComponentMetaNodeModel gxtComponentMetaNodeModel) {

		FormData formData = createDefaultFormData();
		
		if (gxtComponentMetaNodeModel.get(FormDataModelEnum.HIGHT.name().toLowerCase())!=null) {
			
			Integer height = (Integer)gxtComponentMetaNodeModel.get(FormDataModelEnum.HIGHT.name().toLowerCase());
			formData.setHeight(height);
			
		}
		if (gxtComponentMetaNodeModel.get(FormDataModelEnum.WIDTH.name().toLowerCase())!=null) {
			
			Integer width=(Integer)gxtComponentMetaNodeModel.get(FormDataModelEnum.WIDTH.name().toLowerCase());
			formData.setWidth(width);
		
		}
		return formData;
	}

	private static FormData createDefaultFormData() {

		FormData formData = new FormData("100%");

		return formData;
	}
}
